Merged
Conversation
…d .scrutinizer.yml
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #35 +/- ##
============================================
+ Coverage 90.67% 99.67% +9.00%
- Complexity 260 265 +5
============================================
Files 16 19 +3
Lines 461 613 +152
============================================
+ Hits 418 611 +193
+ Misses 43 2 -41 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several major features and improvements to the WP REST Schema library, focusing on enhanced combinator support, improved handling of defaults and enums, and expanded documentation. The most important changes are the addition of root-level combinator types (
One_Of_TypeandAny_Of_Type), support for explicit null/falsy defaults, mixed-type enums, and the introduction ofarg_optionsandrequired_properties. Several methods have also been deprecated for clarity.Combinator Support and Object Schema Enhancements:
Combinator_Typebase class and concreteAny_Of_Typefor schema-root combinators, allowing schemas to express "one of" or "any of" relationships between variants. This enables advanced schema validation and clearer API contracts. (src/Argument/Combinator_Type.php[1]src/Argument/Any_Of_Type.php[2]required_properties()method to bothObject_TypeandSchema, allowing explicit marking of required object properties in the schema output, matching WordPress core conventions. (src/Argument/Object_Type.php,docs/Object-Type.md[1]docs/Schema.md[2]Defaults and Enum Handling:
default()now accepts null and all falsy values, and tracks explicit set-ness separately from the value, ensuring correct schema emission and introspection. (src/Argument/Argument.php[1] [2] [3]expected()(enum) to accept any JSON-comparable value, including null, arrays, and objects, to match WP's internal validation semantics. (src/Argument/Argument.php[1] [2]WP REST Integration and Extensibility:
arg_options()method, enabling per-property pass-through of raw WP REST controller options (e.g.,sanitize_callback,validate_callback) via the schema. (src/Argument/Argument.phpsrc/Argument/Argument.phpR566-R589)Deprecations and Documentation:
name()andall_of()methods, as they are either not part of WP REST schema or are no-ops under current WP behavior. (src/Argument/Argument.php[1]src/Argument/Attribute/Element_Requirements.php[2]README.md[1] [2]docs/Argument.md[3] [4] [5] [6]docs/Array-Type.md[7]docs/Object-Type.md[8]docs/Schema.md[9]These changes make the schema builder more expressive, more closely aligned with WordPress core, and easier to use for complex API schemas.